<template>
    <el-dialog v-dialog-drag :title="$t('UploadImg')" :visible.sync="addUploadDialog" :width="modalWidth"
               :before-close="handleUploadDialogClose">

        <div>
            <el-upload
                :action="uploadUrl"
                list-type="picture-card"
                :on-preview="handlePictureCardPreview"
                :on-remove="handleRemove"
                :multiple="true"
                :headers="headerInfo"
            >
                <i class="el-icon-plus"></i>
            </el-upload>
            <el-dialog :visible.sync="dialogVisible">
                <img width="100%" :src="dialogImageUrl" alt="">
            </el-dialog>
        </div>

    </el-dialog>
</template>

<script>
    import * as appServer from '../../store/appServerParams.js'
    import * as util from '../../assets/util.js';
    export default {
        props:{
            addUploadDialog:false
        },
        data() {
            return {
                dialogImageUrl: '',
                dialogVisible: false,
                uploadUrl : appServer.BASE_URL+"/photo/uploadPhotos" ,
                headerInfo:{
                    Authorization:util.local(appServer.TOKEN),
                    projectId : this.$parent.projectId ,
                },
                modalWidth : "860px",
            };
        },
        methods: {
            handleUploadDialogClose(done){
                this.$parent.getImgFromServer();
                this.$parent.addUploadDialog = false
            },
            handleRemove(file, fileList) {
                console.log(file, fileList);
            },
            handlePictureCardPreview(file) {
                this.dialogImageUrl = file.url;
                this.dialogVisible = true;
            },
        },
        created() {

        },
        mounted() {
        },
    }
</script>

<style scoped>

</style>
